import axios from '@/utils/myaxios';

// 获取酒店类型数据
export const hotelsoptions = () => {
  return axios({
    url: "/hotels/options",
  });
};


// 获取城市位置
export const postcities = (name) => {
  return axios({
    url: "/cities",
    params: { name }
  });
};


export const cityposition = (data) => {
  return axios({
    url: "/hotels",
    params: data
  });
};



// 城市菜单列表
export const recCity = () => {
  return axios({
    url: '/posts/cities'
  });
};

// 文章列表
export const posts = (city) => {
  return axios({
    url: '/posts',
    params: { city }
  });
};

// 文章详情
export const articles = (id) => {
  return axios({
    url: '/posts',
    params: { id }
  });
};

// 推荐文章
export const recPost = (id) => {
  return axios({
    url: '/posts/recommend',
    params: { id }
  });
};

// 文章评论
export const sendPostComment = (data, token) => {
  return axios({
    method: 'post',
    url: '/comments',
    data,
    headers: {
      Authorization: 'Bearer ' + token
    },
  });
};

// 获取文章评论
export const postComment = (params) => {
  return axios({
    url: '/posts/comments',
    params
  });
};

// 上传接口
export const upload = (data) => {
  return axios({
    method: 'post',
    url: '/upload',
    data
  });
};

// 新增文章
export const addPost = (data, token) => {
  return axios({
    method: 'post',
    url: '/posts',
    data,
    headers: {
      Authorization: 'Bearer ' + token
    },
  });
};

// 查找城市
export const cities = name => {
  return axios({
    url: '/cities',
    params: { name }
  });
};